import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  assetsDir: 'assets',
  define: {
    // enable hydration mismatch details in production build
    __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true'
  },
  plugins: [
    vue(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(__dirname, 'src/assets/icons/svg')],
      symbolId: "icon-[name]", // symbol的id
      inject: "body-last", // 插入的位置
      customDomId: "__svg__icons__dom__" // svg的id
    })
  ],
  resolve: {
    alias: {
      '@': path.resolve('./src')
    }
  },
  server: {
    open: true,
    // 设置反向代理
    proxy: {
      // '/api': {
      //   target: 'http://192.168.3.248:80', // 后端API服务器的地址和端口
      //   changeOrigin: true, // 是否改变源地址
      //   rewrite: (path) => path.replace(/^\/api/, ''), // 重写路径
      // },
    },
  },
})
